<?php

class ZendRegistryAdapter implements IRegistry
{
    private $_componentInstance = null;
    
    public function __construct()
    {
        $this->_componentInstance = Zend_Registry::getInstance();
    }
    
    public function __set($key, $value)
    {
        $this->_componentInstance->$key = $value;
    }
    
    public function __get($key)
    {
        if($value = $this->_componentInstance->isRegistered($key))
        {
            return $this->_componentInstance->$key;
        }
        
        return $value;
    }
    
    public function __isset($key)
    {
        return $this->_componentInstance->isRegistered($key);
    }
    
    public function set($key, $value)
    {
        $this->_componentInstance->set($key, $value);
    }
    
    public function get($key)
    {
        return $this->_componentInstance->get($key);
    }
    
    public function toArray()
    {
        return Zend_Registry::getInstance();
    }
    
    public function reload()
    {
        Zend_Registry::_unsetInstance();
        $this->_componentInstance = Zend_Registry::getInstance();
    }
    
    public function isRegistered($key)
    {
        return Zend_Registry::isRegistered($key);
    }
}
?>